﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using A2DFramework.EventService;
using A2DFramework.CacheService.CacheEvents;
using A2DFramework.CacheService.Configuration;

namespace A2DFramework.CacheService.CacheEventHandlers
{
    public class CachePutEventHandler : IProcessReceivedEventProcessorHandler<CachePutEvent>
    {
        public void Process(CachePutEvent evt)
        {
            CacheCore core=CacheManager.Instance().GetCacheCore(evt.Location);
            if ((CacheConfiguration.Storages[evt.Location].DistributedCacheSetting_PeerCacheServers != null
                && CacheConfiguration.Storages[evt.Location].DistributedCacheSetting_PeerCacheServers.Count > 0)
                ||
                (CacheConfiguration.Storages[evt.Location].DistributedCacheSetting_BackupCacheServer != null))
            {
                object o = core.GetRemote(evt.Key);//get cache item from remote cache server
                core.Set(evt.Key, o);
            }
        }
    }
}
